﻿<%@ Page Title="Информация о пользователях" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Users.aspx.cs" Inherits="MusaDor.Admin.Users" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="PageContent">
        <div class="Navigaton">
            <asp:ListView ID="UserList" DataKeyNames="UserName" runat="server" 
                DataSourceID="UsersSqlDataSource" onitemcommand="UserList_ItemCommand" 
                onselectedindexchanged="UserList_SelectedIndexChanged">
                <LayoutTemplate>
                    <div ID="itemPlaceholder" runat="server">
                    </div>
                </LayoutTemplate>  
                <ItemTemplate> 
                    <asp:LinkButton ID="LinkButton1" Text='<%# Eval("UserName") %>' CommandName="Select" runat="server" />
                </ItemTemplate>
            </asp:ListView>
            <asp:SqlDataSource ID="UsersSqlDataSource" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                            SelectCommand="SELECT [UserId], [UserName] FROM [vw_aspnet_MembershipUsers]">
            </asp:SqlDataSource>
        </div>
        <div ID="Section"  runat="server" visible="false" class="Section" clientidmode="Inherit">
            <div id="RightSide">
                <asp:FormView ID="UsersDetails" DataSourceID="UsersDetailsDataSource" 
                        runat="server"  CssClass="SectionData">
                    <ItemTemplate>
                            <asp:Label ID="Name" runat="server" Text="Username:" CssClass="miniTitle"></asp:Label>
                            <br />
                            <asp:Label ID="NameOfUser" Text='<%# Bind("UserName") %>' runat="server" />
                            <br />
                            <br />
                            <asp:Label ID="Email" runat="server" Text="E-mail:" CssClass="miniTitle"></asp:Label>
                            <br />
                            <asp:Label ID="SectionSubtitleLabel" runat="server" Text='<%# Bind("Email") %>' />
                            <br />
                            <br />
                            <asp:Label ID="CreateDate" runat="server" Text="Date of registration:" CssClass="miniTitle"></asp:Label>
                            <br />
                            <asp:Label ID="DateOfCreate" runat="server" Text='<%# Bind("CreateDate") %>' />
                            <br />
                            <br />
                            <asp:Label ID="LastLogin" runat="server" Text="Last login date:" CssClass="miniTitle"></asp:Label>
                            <br />
                            <asp:Label ID="LastLoginDate" runat="server" Text='<%# Bind("LastLoginDate") %>' />
                            <br />
                            <br />
                    </ItemTemplate>
                </asp:FormView>
                <asp:Label ID="Role" runat="server" CssClass="miniTitle" Text="Role:" Visible="false"></asp:Label>
                <br />
                <asp:Label ID="RoleOfUser" runat="server"/>
                <br />
                <br />
                <div class="bp" runat="server" ID="AddToRole" visible="false">
                    <asp:Button ID="Admin" runat="server" Text="Administrator" 
                        onclick="Admin_Click" CssClass="Role" />
                    <asp:Button ID="Publisher" runat="server" Text="Publisher" 
                        onclick="Publisher_Click" CssClass="Role" />
                    <asp:Button ID="JustUser" runat="server" Text="User" 
                        onclick="JustUser_Click" CssClass="Role" />
                </div>
                <br />
                <asp:DetailsView ID="Approved" runat="server" Width="230px" 
                    AutoGenerateRows="False" DataKeyNames="UserName" 
                    DataSourceID="UserApprovedSqlDataSource" GridLines="None" 
                    CssClass="Approved">
                    <Fields>
                        <asp:CheckBoxField DataField="IsApproved" HeaderText="Approved" 
                            SortExpression="IsApproved" />
                        <asp:CommandField ShowEditButton="True" />
                    </Fields>
                </asp:DetailsView>
                <br />
                <br />
                <div class="bp">
                    <asp:Button ID="DelUser" runat="server" CssClass="Send"  
                        Text="Delete user"  Width="170px" Visible="False" 
                        PostBackUrl="#DeleteUser" onclick="DelUser_Click" />
                </div>
            </div>
        </div>
                <asp:SqlDataSource ID="UserApprovedSqlDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                    
                    SelectCommand="SELECT [UserName], [IsApproved] FROM [vw_aspnet_MembershipUsers] WHERE ([UserName] = @UserName)"
                    
                    UpdateCommand="UPDATE [vw_aspnet_MembershipUsers] SET [IsApproved] = @IsApproved WHERE ([UserName] = @UserName)">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="UserList" DefaultValue="NULL" Name="UserName" 
                            PropertyName="SelectedValue" Type="Object" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="IsApproved" Type="Boolean" />
                        <asp:Parameter Name="UserName" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            <asp:SqlDataSource ID="UsersDetailsDataSource" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                
                SelectCommand="SELECT [UserId], [Email], [IsApproved], [IsLockedOut], [CreateDate], [LastLoginDate], [UserName] FROM [vw_aspnet_MembershipUsers] WHERE ([UserName] = @UserName)"  >
                <SelectParameters>
                    <asp:ControlParameter ControlID="UserList" DefaultValue="NULL" Name="UserName" 
                        PropertyName="SelectedValue" Type="Object" />
                </SelectParameters>
            </asp:SqlDataSource>           
    </div>
    <a href="#DeleteUser" class="overlay" id="DeleteUser"></a>
    <div class="popup">
        <a class="close" title="Закрыть" href="#close"></a>
        <center>
            <br />
                Do you want to delete this user?
            <br />
                <div class="bp">
                    <center>
                        <br />
                        <asp:Button ID="DeleteTheUser" runat="server" CssClass="Send"  Text="Delete" onclick="DeleteUser_Click"   Width="100px" PostBackUrl="#DelUser" />                    
                    </center>
                </div>              
        </center>
    </div>    
</asp:Content>
